import { reactive } from 'vue'

export interface IArticleSort {
    type: string,
    id: string | number,
    name: string,
    ord: string | number,
    pid: number,
    is_active: boolean
}


export default function useArticleSortModel() {
    //初始化数据
    const iArticleSortModel = (): IArticleSort => {
        return {
            type: '',
            id: 0,
            name: '',
            ord: 0,
            pid: 0,
            is_active: false
        }
    }

    // 菜单验证规则
    const articleSortRules = reactive({
        name: [{
            required: true,
            message: '请分类名称！',
            trigger: 'blur',
        }, {
            max: 32,
            message: '最大长度32位',
            trigger: 'blur'
        }],
        ord: [{
            required: true,
            pattern: /^(0|[1-9][0-9]*)$/,
            message: '请填写数字！',
            trigger: 'blur',
        }]
    })

    return { iArticleSortModel, articleSortRules }
}